<template>
  <div>
    <el-container>
      <el-header
        ><el-button
          @click="drawer = true"
          type="primary"
          style="margin-left: 16px"
          >+创建店铺优惠券
        </el-button></el-header
      >
      <el-main
        ><Discountsmell
          v-for="item in userCouponData"
          :key="item.id"
          :userCoupon="item"
        />
      </el-main>
    </el-container>

    <el-drawer
      title="优惠创建"
      :visible.sync="drawer"
      :direction="direction"
      :before-close="handleClose"
      :size="'80%'"
    >
      <div>
        <el-form label-width="80px" :model="userFrom">
          <el-form-item label="活动名称">
            <el-input v-model="userFrom.discount"></el-input>
          </el-form-item>
          <el-form-item label="活动日期">
            <el-input v-model="userFrom.active"></el-input>
          </el-form-item>
          <el-form-item label="活动区域">
            <el-input v-model="userFrom.money"></el-input>
          </el-form-item>
          <el-form-item label="负责人">
            <el-input v-model="userFrom.number"></el-input>
          </el-form-item>
          <el-form-item label="负责人">
            <el-input v-model="userFrom.spoce"></el-input>
          </el-form-item>
        </el-form>

        <el-button type="primary" @click="confirme">提交</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import Discountsmell from "@/views/marketing/DiscountCoupon/DiscountSmell.vue";
import { apimockactivitys } from "@/views/marketing/DiscountCoupon/mockActivityregister";
export default {
  name: "DiscountCouponcomponent",
  components: { Discountsmell },
  data() {
    return {
      drawer: false,
      direction: "btt",
      userFrom: {
        active: "",
        money: "",
        number: "",
        spoce: "",
        discount: "",
      },
      userCouponData: [],
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((res1) => {
          console.log(res1);
          done();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //接口请求
    require() {
      apimockactivitys.getAll().then((res) => {
        console.log(res);
        this.userCouponData = res;
      });
    },
    confirme() {
      apimockactivitys.append(this.userFrom).then((res) => {
        console.log(res);
      });
    },
  },
  mounted() {
    this.require();
  },
};
</script>

<style scoped lang="scss">
.el-header {
  background-color: #b3c0d1;
  color: #333;
  // text-align: center;
  line-height: 60px;
}
/* 
.el-main {
  background-color: #e9eef3;
  color: #333;

  text-align: center;
  line-height: 160px;
}
.el-main > div {
  flex: 1;
}
.el-main > div > img {
  width: 120px;
  height: 120px;
  margin: 5px;
} */
</style>
